import pymysql
import xml.dom.minidom
import re

dom= xml.dom.minidom.parse("WDT.testsuite-deep.xml")

root = dom.documentElement

conn=pymysql.connect(
    host='localhost',
    port=3306,
    user='root',
    passwd='111',
    db='test',
    charset='utf8'
     )
cur=conn.cursor()

cur.execute('create table vidio(\
            summary varchar(1000),\
            active varchar(100))')


for i in range(0,10):
    list_1 = []
    summary = root.getElementsByTagName('summary')[i].firstChild.data   #获取summary
    list_1.append(summary)
    active = root.getElementsByTagName('active')[i].firstChild.data     #获取active
    list_1.append(active)
    print(list_1)
    cur.execute('insert into vidio values(%s,%s)',list_1)

cur.close()
conn.commit()
conn.close()

# for oneper in p:
#     values=[]
#     print(oneper.getElementsByTagName("preconditions"))
#     for child in oneper.getchildren():
#         values.append(child.text)
#     cur.execute('insert into vidio values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)',values)

# cur.close()
# conn.commit()
# conn.close()


# cur.execute('create table vidio(\
#             vidioUrl varchar(100),\
#             node_order varchar(100),\
#             externalid varchar(100),\
#             version varchar(100),\
#             summary varchar(100),\
#             preconditions varchar(100),\
#             execution_type varchar(100),\
#             importance varchar(100),\
#             estimated_exec_duration varchar(100),\
#             status varchar(1000),\
#             active varchar(1000))')
 
# for oneper in p:
#     print(oneper)
#     values=[]
#     print(oneper.getElementsByTagName("preconditions"))
#     for child in oneper.getchildren():
#         values.append(child.text)
#     cur.execute('insert into vidio values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)',values)
# cur.close()
# conn.commit()
# conn.close()
 
 
